package speedball.start;

import javafx.animation.FadeTransition;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class StartAnimation extends Stage {

    private static String repath="/img/logo/";
    private static List<String> logoFiles=new ArrayList<>();

    static{
        logoFiles.add(repath+"5cf516b92f288b009d620425.png");
        logoFiles.add(repath+"5cf516ba9514c6005704a384.png");
        logoFiles.add(repath+"5cf516bc2f288b009f37a427.png");
        logoFiles.add(repath+"5cf516ca2f288b009f37a435.png");
        logoFiles.add(repath+"5cf516ce12d6c900622b768a.png");
        logoFiles.add(repath+"5cf516d02f288b009d62043c.png");
        logoFiles.add(repath+"5cf516d12f288b009e7c2f79.png");
//        logoFiles.add("5cf522749514c60058ad60c6.png");
//        logoFiles.add("5cf5228c2f288b009d6207cb.png");
//        logoFiles.add("5cf522942204c5002aa19469.png");
//        logoFiles.add("5cf522a54a6a1000989b6ce5.png");
//        logoFiles.add("5cf523fa12d6c90058921f63.png");
    }





    public StartAnimation() {
        initStyle(StageStyle.TRANSPARENT);
        Group group = new Group();
        ImageView imageView = new ImageView();

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0){w = 0;}

        System.out.println(w);
        imageView.setImage(new Image(logoFiles.get(w)));

        FadeTransition imageViewFade = new FadeTransition(Duration.millis(2000), imageView);
        imageViewFade.setFromValue(0.0);
        imageViewFade.setToValue(1.0);
        imageViewFade.setCycleCount(2);
        imageViewFade.setAutoReverse(true);
        imageViewFade.play();
//

//        StackPane stackPane=new StackPane();
//        MySpinner greenSpinner =new MySpinner();
//
//        greenSpinner.setStartingAngle(0);
//        greenSpinner.setProgress(0.00D);
//        greenSpinner.setRadius(500.00D);
////        greenSpinner.getStyleClass().add("first-spinner");
//        greenSpinner.setStyle("-fx-stroke: #00c853;");
////-jfx-radius: 500.00;
//        stackPane.getChildren().add(greenSpinner);

//        " styleClass="materialDesign-green, first-spinner" progress="0"
//        startingAngle="0" style="-jfx-radius:100;"/>


        group.getChildren().addAll( imageView);


        Scene scene = new Scene(group);
        scene.setFill(Color.TRANSPARENT);
        setScene(scene);
        setAlwaysOnTop(true);
    }




}
